package com.yf.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yf.domain.security.User;
import com.yf.model.query.UserQueryCriteria;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Set;

/**
 * @author chentianwei
 * @date 2023/4/17 10:53
 * @description 用户Dao
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {

    /**
     * 更新用户邮箱
     * @param username 用户名
     * @param email 邮箱
     */
    void updateEmail(@Param("username") String username,
                     @Param("email") String email);

    List<User> findByMenuId(@Param("menuId") Long menuId);

    List<User> findByRoleDeptId(@Param("deptId") Long deptId);

    int countByDepts(@Param("deptIds") Set<Long> deptIds);

    List<User> findByRoleId(@Param("roleId") Long roleId);

    int countByRoles(@Param("roleIds") Set<Long> roleIds);

    int countByJobs(@Param("jobIds") Set<Long> jobIds);

    List<User> findAll(@Param("criteria") UserQueryCriteria criteria);

    Long countAll(@Param("criteria") UserQueryCriteria criteria);

    User findByUsername(@Param("username") String username);

    User findByEmail(@Param("email") String email);

    User findByPhone(@Param("phone") String phone);

    void resetPwd(@Param("userIds") Set<Long> userIds, @Param("pwd") String pwd);
}
